static class ActorManager
{
- static Game Game;
+ static SuperPolarity Game;
static int OutlierBounds;
- static List<Actor> Actors;
+ static IList<Actor> Actors;
static ActorManager()
{
static void CheckActors()
{
- var i = 0;
- foreach (Actor actor in Actors)
+ for (var i = Actors.Count - 1; i >= 0; i--)
{
- i++;
- foreach (Actor other in Actors.Skip(i))
+ if (i >= Actors.Count) {
+ i = Actors.Count - 1;
+ }
+ Actor actor = Actors[i];
+ for (var j = i - 1; j >= 0; j--)
{
+ Actor other = Actors[j];
+
CheckCollision(actor, other);
if (actor.GetType().IsSubclassOf(typeof(Ship)) && other.GetType().IsSubclassOf(typeof(Ship)))
static void CheckCollision(Actor actor, Actor other)
{
+ var collision = Rectangle.Intersect(actor.Box, other.Box);
+ var inverseCollision = Rectangle.Intersect(other.Box, actor.Box);
+ if (!collision.IsEmpty && !actor.Dying && !other.Dying)
+ {
+ actor.Collide(other, collision);
+ other.Collide(actor, inverseCollision);
+ }
}
}
}
- internal static void SetGame(Game game)
+ internal static void SetGame(SuperPolarity game)
{
Game = game;
}